package cmd

import (
	"fmt"
	"github.com/spf13/cobra"
	"oolee.com/primary/cmd/api"
	"oolee.com/primary/cmd/env"
	"oolee.com/primary/cmd/version"
	"os"
)

var ServerCmd = &cobra.Command{
	Use:          "primary",
	Short:        "primary",
	Long:         "primary",
	SilenceUsage: true,
	Run: func(cmd *cobra.Command, args []string) {
		hello()
	},
}

func hello() {
	fmt.Println("welcome to use primary ~")
	fmt.Println("if you have any problems, please contact to @ooLee")
}

func init() {
	fmt.Println("init cmd ...")
	ServerCmd.AddCommand(version.Cmd)
	ServerCmd.AddCommand(api.Cmd)
	ServerCmd.AddCommand(env.Cmd)
}

func Execute() {
	if err := ServerCmd.Execute(); err != nil {
		os.Exit(-1)
	}
	fmt.Println("server init over ...")
}
